<template>
	<view class="content">
		<view class="nav-part-bg"></view>
		<view class="nav-day">
			<view class="search">
				<u-search placeholder="输入车辆编号或车牌号" :showAction="false" :clearabled="true" shape="square" v-model="keyword"></u-search>
			</view>
		</view>
		<view class="showbody" v-if="spotlist.length">
			<view class="header" v-for="(item, index) in spotlist" :key="index">
				<view class="row">
					<view class="line">
						<u-tag :text="'站点：' + item.name" @click="selectSpot(item)"></u-tag>
					</view>
					<view class="row-tip">
						<view class="cell">
							<text class="cell-title">联系人：</text>
							<text class="cell-content">{{ item.linkman }}</text>
							<text class="cell-content">{{ item.phone }}</text>
						</view>
						<view class="cell">
							<text class="cell-title">站点备注：</text>
							<text class="cell-content">{{ item.remark }}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<empty class="showbody" v-else text="暂无数据"></empty>
	</view>
</template>

<script>
import { mapGetters } from 'vuex';
import spotlistjs from '@/api/spotlist.js';
import common from '@/utils/common.js';
import empty from '@/components/empty.vue';
export default {
	components: { empty },
	async onLoad() {
		// #ifdef MP
		//未登录转登录页面，已登录转主页面
		if (!this.$store.dispatch('checkIndentity')) return;
		// #endif
		let res = await spotlistjs.getSpotList(this.token);
		if (common.httpIsWrong(res)) return;
		this.spotlist = res.json.data.data;
	},
	computed: { ...mapGetters(['token']) },
	methods: {
		selectSpot(item) {
			let pages = getCurrentPages();
			let prevPage = pages[pages.length - 2];
			prevPage.$vm.spotID = item.id;
			prevPage.$vm.spotName = item.name;
			uni.navigateBack({
				delta: 1
			});
		}
	},
	data() {
		return {
			spotlist: []
		};
	}
};
</script>

<style lang="scss">
.content {
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	overflow: scroll;
	padding-top: 100rpx;
	background-color: white;
	.nav-part-bg {
		width: 100%;
		height: 100rpx;
		background-color: #1a90e4;
		position: fixed;
		top: 0;
		z-index: 0;
	}
	.nav-day {
		width: 100%;
		height: 100rpx;
		color: white;
		background-color: #1a90e4;
		position: fixed;
		top: var(--window-top, 0);
		z-index: 99;
		.search {
			margin: 0 20rpx;
		}
	}
	.showbody {
		width: 100%;
		.header {
			width: 100%;
			height: auto;
			background-color: white;
			.row {
				margin: 20rpx 20rpx 0 20rpx;
				align-items: center;
				border: solid 1rpx #3c9cff;
				border-radius: 10rpx;
				background-color: #f1f2f4;
				.line {
					width: 100%;
					position: relative;
				}
				.row-tip {
					margin: 10rpx 20rpx;
					display: flex;
					flex-direction: column;
					.tip-m {
						color: #3c9cff;
					}
					.cell {
						padding: 10rpx 0;
						display: flex;
						.cell-title {
							letter-spacing: 10rpx;
							font-size: 28rpx;
						}
						.cell-content {
							letter-spacing: 10rpx;
							font-size: 28rpx;
							color: #1a90e4;
							margin: 0 20rpx;
						}
						.cell-content2 {
							font-size: 28rpx;
							color: #1a90e4;
							margin: 0 20rpx;
						}
						.cell-row-left {
							width: 40%;
						}
						.cell-row-right {
							flex: 1;
						}
						.cell-row {
							width: 50%;
						}
					}
				}
			}
		}
	}
}
</style>
